import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

import 'AddPartsState.dart';

class AddPartsController extends GetxController {
  final AddPartsState state = AddPartsState();

  bool isInputData(){
    if(state.partsNameController.text.isEmpty){
      Fluttertoast.showToast(
        msg: "请输入部件名称",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
      );
      return false;
    }
    if(state.partsIdController.text.isEmpty){
      Fluttertoast.showToast(
        msg: "请输入或扫描部件ID",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
      );
      return false;
    }
    return true;
  }

  @override
  void onInit() {
    super.onInit();
    state.eqpId = Get.arguments;
  }
}
